﻿<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ page import="nc.vo.sm.UserVO"%>
<%@ page import="nc.bs.ebvp.login.Constant"%>
<%@ page import="nc.vo.ebpur.supinfocheck.AggSupInfoCheckVO"%>
<%@ page import="nc.vo.ebpur.supinfocheck.SupInfoCheckVO"%>
<%@ page import="nc.bs.ebvp.sourcingcoll.Constants"%>
<%@ page import="nc.bs.ebvp.sourcingcoll.form.ProjectForm"%>
<%@ page import="nc.bs.ebvppub.ebvpservicefactory.LoadConfigProperty"%>
<%
	String basePath = request.getContextPath();
	String host = (String)request.getAttribute(Constants.ID_EBPUR_SERVER_IP);
	String strParaEc021 = (String) request.getSession().getAttribute(Constants.ID_EC021);
	UserVO userVo = (UserVO) request.getSession().getAttribute(Constant.USER_INFO);
	boolean isClientCa = false;
	//供应商客户端是否支持CA
	if ("Y".equalsIgnoreCase(strParaEc021) || (null != userVo.getIsca() && userVo.getIsca().booleanValue())) {
		isClientCa = true;
	}
	//CA厂商名称
	String strCaFactory = (String)request.getSession().getAttribute(LoadConfigProperty.EBVP_CA_FACTORY);
	//供应商主键
	AggSupInfoCheckVO aggSuppInfoVo = (AggSupInfoCheckVO) request.getSession().getAttribute(
			Constant.SUP_CHECK_INFO);
	String strSuppPk = aggSuppInfoVo.getParentVO().getAttributeValue(SupInfoCheckVO.PK_VENDOR_BD).toString();
	String strSuppName = aggSuppInfoVo.getParentVO().getAttributeValue(SupInfoCheckVO.SUPNAME).toString();
	Object strTotalPrice = request.getAttribute(Constants.ID_PRICE_TOTAL);
	String strPara11 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA11).toString();
	String strPara12 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA12).toString();
	String strPara21 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA21).toString();
	String strPara22 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA22).toString();
	String strPara31 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA31).toString();
	String strPara32 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA32).toString();
	String strPara4 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA4).toString();
	String strPara5 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA5).toString();
	String strPara6 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA6).toString();
	String strPara7 = request.getAttribute(Constants.ID_ONLINEQUOTE_PARA7).toString();
	String strPwd = (String)request.getAttribute(Constants.ID_LOGIN_PWD);
	//数据源
	String strDataSource = (String)request.getSession().getAttribute("data_source");
	//获取服务器IP和端口
	String strServerName = request.getServerName();
	//环节执行状态
	String strStepExeStatus = request.getAttribute(Constants.ID_PROJ_STEP_STATUS).toString();;
	int intServerPort = request.getServerPort();
	ProjectForm projForm = (ProjectForm)request.getAttribute(Constants.ID_PURPROJECT_FORM);
	String strIsPartPrice = projForm.getIsPartPrice();
%>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<script type="text/javascript" src="js/jquery.form.js"></script>
		<%
			if (isClientCa) {
		%>
			<%if(Constants.CA_FACTORY_ITRUS.equals(strCaFactory)){%>
				<script type="text/javascript" src="js/itrusforNC.js"></script>
				<script type="text/javascript" src="js/pta.js"></script>
			<%} else if(Constants.CA_FACTORY_INFOSEC.equals(strCaFactory)){%>
				<script type="text/javascript" src="js/Infosec4NC.js"></script>
			<%} else if(Constants.CA_FACTORY_DEAN.equals(strCaFactory)){%>
				<script type="text/javascript" src="js/DatechJs.js"></script>
			<%} %>
		<%
			}
		%>
		<script type="text/javascript">
		$(document).ready(function() {
		var options = {
			beforeSubmit : showRequest, 
			success : showResponse
			};
			$('#quoteform').ajaxForm(options);
		});
		</script>
	</head>
	<body class="fullbody">
		<form id="quoteform" name="quoteform" method="post" action="<%=basePath%>/sourcing/biddingprojlist/doquote">
		<input type="hidden" id="pk_onlinequote_h" name="pk_onlinequote_h" value="${ONLINEQUOTE_FORM.pk_onlinequote_h}"/>
		<input type="hidden" id="quote_type" name="quote_type" value="${ONLINEQUOTE_FORM.quote_type}"/>
		<input type="hidden" id="data_submit" name="data_submit" value=""/>
		<input type="hidden" id="casn" name="casn" value=""/>
		<input type="hidden" id="is_mny_down" name="is_mny_down" value="${ONLINEQUOTE_FORM.is_mny_down}"/>
		<input type="hidden" id="down_percent" name="down_percent" value="${ONLINEQUOTE_FORM.down_percent}"/>
		<input type="hidden" id="down_price" name="down_price" value="${ONLINEQUOTE_FORM.down_price}"/>
		<input type="hidden" id="down_percent_mny" name="down_percent_mny" value="${ONLINEQUOTE_FORM.down_percent_mny}"/>
		<input type="hidden" id="down_price_mny" name="down_price_mny" value="${ONLINEQUOTE_FORM.down_price_mny}"/>
		<input type="hidden" id="low_price" name="low_price" value="${ONLINEQUOTE_FORM.low_price_supp}"/>
		<div class="context">
			<div class="position">
				<div class="tposi">
					当前位置：
					<a href="<%=basePath%>/infopub/pubmain"	class="linkstyle">首页</a> &nbsp;&gt;&gt;&nbsp;
					<a href="<%=basePath%>/sourcing/projlist" class="linkstyle">我的投标\谈判\询价</a> &nbsp;&gt;&gt;&nbsp;
					<a href="<%=basePath%>/sourcing/biddingprojlist" class="linkstyle">进行中的项目</a> &nbsp;&gt;&gt;&nbsp;
					<a href="<%=basePath%>/sourcing/biddingprojlist/projexec?pk_pur_project=${PURPROJECT_FORM.pk_pur_project}" class="linkstyle">${PURPROJECT_FORM.project_name}</a> &nbsp;&gt;&gt;&nbsp;
					<span class="curposition">在线竞价</span>
				</div>
				<div class="help">
					<a href="javascript:void(null);" onClick="doHelp('<%=request.getContextPath()%>/help/html/ZXJJ.html');" class="linkstyle">帮助</a>
				</div>
			</div>
			<div class="margin8">
			</div>
			<div class="subpage_title">
				<div class="title_index">
					<img src="<%=basePath%>/images/common/dot03.gif" alt="" border="0" />&nbsp;&nbsp;在线竞价
				</div>
				<div class="rollback">
					<a href="<%=basePath%>/sourcing/biddingprojlist" class="linkstyle">&lt;&lt;&nbsp;返回进行中的项目</a>
				</div>
			</div>
			<div class="bidroom">
				<div>
				<b>${QUOTE_INFORM}</b>
				</div>
				<OBJECT classid="clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA" name="OnlineQuote" codebase="http://<%=strServerName%>:<%=intServerPort%>/Client/jre-6u24-windows-i586.exe" style="" width="794px" height="188" >
					<param name="java_code" value="nc.ui.ebvp.sourcingcoll.OnlineQuoteApplet">
					<param name="java_archive" value="/ebvp/onlinequote.jar,/ebvp/onlinequotecomm.jar,/ebvp/dom4j.jar,/ebvp/jaxen.jar,/ebvp/jdom.jar,/ebvp/jmdns.jar,/ebvp/jzlib.jar,/ebvp/mina-core.jar,/ebvp/mina-filter-compression.jar,/ebvp/mina-filter-ssl.jar,/ebvp/stringprep.jar,/ebvp/xpp3.jar,/ebvp/commons-logging.jar">
					<param name="type" value="application/x-java-applet;version=1.6">
					<param name="scriptable" value="true">
					<param name="host" value="<%=host%>" />
					<param name="data_source" value="<%=strDataSource%>" />
					<param name="quote_type" value="${ONLINEQUOTE_FORM.quote_type}" />
					<param name="pk_onlinequote_h" value="${ONLINEQUOTE_FORM.pk_onlinequote_h}" />
					<param name="pk_supplier" value="<%=strSuppPk%>" />
					<param name="supplier_name" value="<%=strSuppName%>" />
					<param name="login_pwd" value="<%=strPwd%>" />
					<param name="quote_price" value="<%=strTotalPrice%>" />
					<param name="mny_precision" value="${MONEY_PRECISION}" />
					<param name="show_latest_price" value="${ONLINEQUOTE_FORM.is_latest_price}" />
					<param name="show_latest_index" value="${ONLINEQUOTE_FORM.is_list}" />
					<param name="step_status" value="<%=strStepExeStatus%>" />
					<param name="para11" value="<%=strPara11%>" />
					<param name="para12" value="<%=strPara12%>" />
					<param name="para21" value="<%=strPara21%>" />
					<param name="para22" value="<%=strPara22%>" />
					<param name="para31" value="<%=strPara31%>" />
					<param name="para32" value="<%=strPara32%>" />
					<param name="para4" value="<%=strPara4%>" />
					<param name="para5" value="<%=strPara5%>" />
					<param name="para6" value="<%=strPara6%>" />
					<param name="para7" value="<%=strPara7%>" />
					要求Java 1.5或更高版本插件.
				</OBJECT>
				<div class="margin20">
				</div>
				<div class="conner1">
					<div class="message">
						<div class="textrow">
							<input type="button" class="buttonok" value="竞价须知" onClick="getQuoteInform();" />
							&nbsp;&nbsp;
							<input type="button" class="buttonadd" value="查看报价历史" onClick="getOldPrice();" />
							&nbsp;&nbsp;
							<input type="button" class="buttonok" value="导出报价" onClick="exportPrice();"/>
							&nbsp;&nbsp;
							<input type="button" class="buttonadd" value="设置降价策略" onClick="setQuoteRule();"/>
						</div>
						<div class="buttonrow">
						</div>
					</div>
				</div>
				<div class="margin10">
				</div>
				<div>
					<b>报价单元</b>
				</div>
				<div class="margin10">
				</div>
				<div>
					<table cellpadding="0" cellspacing="0" class="tableCss">
						<tr class="titleTr">
							<th width="35px">序号</th>
							<th width="208px">报价单元</th>
							<th width="55px">产品项</th>
							<th width="102px">合计金额</th>
							<th width="400px">备注</th>
						</tr>
						<c:if test="${PRICE_FORM != null}">
							<c:forEach items="${PRICE_FORM}" var="price">
								<c:if test="${price.index%2==1}">
									<tr align="left" class="contTr-old"  >
								</c:if>
								<c:if test="${price.index%2==0}">
									<tr align="left" class="contTr-even">
								</c:if>
									<input type="hidden" name="signature" value="${price.signature}"/>
									<input type="hidden" name="pk_pur_project" value="${price.pk_pur_project}"/>
									<input type="hidden" name="pk_purproj_step" value="${price.pk_purproj_step}"/>
									<input type="hidden" name="pk_release_h" value="${price.pk_release_h}"/>
									<input type="hidden" name="pk_pricetplt_h" value="${price.pk_pricetplt_h}"/>
									<input type="hidden" name="pk_supplier" value="${price.pk_supplier}"/>
									<input type="hidden" name="pk_pricedata_h" value="${price.pk_pricedata_h}"/>
									<input type="hidden" name="is_prod_item" value="${price.is_prod_item}"/>
									<td class="td3">${price.index}</td>
									<td class="td3">${price.price_unit}</td>
									<td class="td3">
									<c:if test="${price.is_prod_item == 'Y' || price.is_prod_item == 'y'}">是</c:if>
									<c:if test="${price.is_prod_item == 'N' || price.is_prod_item == 'n'}">否</c:if>
									<input type="hidden" name="is_prod_item_cal" value="${price.is_prod_item}"/>
									</td>
									<td class="td3">
									<input name="total_amount" type="text" 
									<c:if test="${price.is_prod_item == 'N' || price.is_prod_item == 'n'}">class="input-edit" </c:if>
									<c:if test="${price.is_prod_item == 'Y' || price.is_prod_item == 'y'}">class="input-unEdit words-blue" readonly </c:if>
									value="${price.total_amount}" onchange="subReduNum(this,'${MONEY_PRECISION}');" onkeypress="javascript:keyPress(this);" />
									</td>
									<td class="td3">${price.memo}</td>
								</tr>
							</c:forEach>
						</c:if>
					</table>
				</div>
			</div>
			
			<c:if test="${ONLINEQUOTE_FORM.pricetplt_type == '1'}">
				<div class="bidroom">
					<div class="margin20">
					</div>
					<div class="pricelist">
						<div>
							<b>产品信息</b>
						</div>
						<div class="margin10">
						</div>
						<div class="pager">
							<div class="P1">
	<!--							<input type="button" class="buttonok" value="修改价格" onclick="doUptValue('1','1');" />&nbsp;-->
								<input type="button" class="buttonadd" value="批量修改折扣率" onClick="doUptValue('1');" />&nbsp;
								<input type="button" class="buttonadd" value="批量修改税率" onClick="doUptValue('2');" />&nbsp;
							</div>
						</div>
					</div>
	
					<table cellpadding="0" cellspacing="0" class="tableCss">
						<tr class="titleTr">
							<th width="35px">序号</th>
							<th width="267px">产品</th>
							<th width="106px">数量</th>
							<th width="173px">价格</th>
							<th width="219px">备注</th>
						</tr>
						<c:if test="${PRICE_DETAIL_FORM != null}">
							<c:forEach items="${PRICE_DETAIL_FORM}" var="pricedetail">
								<c:if test="${pricedetail.detail_index%2==1}">
									<tr align="left" class="contTr-old"  >
								</c:if>
								<c:if test="${pricedetail.detail_index%2==0}">
									<tr align="left" class="contTr-even">
								</c:if>
									<input type="hidden" name="pk_pricetplt_b" value="${pricedetail.pk_pricetplt_b}"/>
									<input type="hidden" name="pk_pricedata_b" value="${pricedetail.pk_pricedata_b}"/>
									<input type="hidden" name="pk_prod" value="${pricedetail.pk_prod}"/>
									<input type="hidden" name="pk_prod_v" value="${pricedetail.pk_prod_v}"/>
									<input type="hidden" name="pk_prod_cls" value="${pricedetail.pk_prod_cls}"/>
									<input type="hidden" name="pk_prod_unit" value="${pricedetail.pk_prod_unit}"/>
									<input type="hidden" name="prod_src" value="${pricedetail.prod_src}"/>
									<input type="hidden" name="amount" value="${pricedetail.amount}"/>
									<input type="hidden" name="amount_precision" value="${pricedetail.amount_precision}" />
									<td class="td3">${pricedetail.detail_index}</td>
									<td class="td3">
									<span class="prodName">
									<c:if test="${pricedetail.prod_name != null && '' !=pricedetail.prod_name}">													
									${pricedetail.prod_name}
									</c:if>
									<c:if test="${pricedetail.prod_name == null || '' ==pricedetail.prod_name}">													
									${pricedetail.config_note}
									</c:if>
									</span><br/>
									供方产品编码:<input name='sup_prodcode' type='text' id='sup_prodcode' style='width: 78px' class='input-edit'  value='${pricedetail.sup_prodcode}'/><br/>
									<c:if test="${pricedetail.prod_spec!=null && ''!=pricedetail.prod_spec}">规格：${pricedetail.prod_spec}<br/></c:if>
									<c:if test="${pricedetail.prod_type!=null && ''!=pricedetail.prod_type}">型号：${pricedetail.prod_type}<br/></c:if>
									<c:if test="${pricedetail.producer!=null && ''!=pricedetail.producer}">生产厂商：${pricedetail.producer}<br/></c:if>
									<c:if test="${pricedetail.asistantproperty!=null && ''!=pricedetail.asistantproperty}">描述：${pricedetail.asistantproperty}<br/></c:if>
									</td>
									<td class="td3">
									<input name="amount_display" class="input-unEdit words-blue" readonly type="text" value="${pricedetail.amount}" />
									${pricedetail.prod_unit_name}
									</td>
									<td class="td3">
									含税单价：<input name="has_tax_price" type="text" class="input-edit" value="${pricedetail.has_tax_price}" onChange="subReduNum(this,'${PRICE_PRECISION}');doCalPrice(this,'${pricedetail.detail_index}',1);" onKeyPress="javascript:keyPress(this);" /><br/>
									折扣率：<input name="detail_discount" type="text" class="input-edit" 
									<c:choose>
										<c:when test="${pricedetail.detail_discount==null}">
											value="100"
										</c:when>
										<c:otherwise>
											value="${pricedetail.detail_discount}"
										</c:otherwise>
									</c:choose> onChange="subReduNum(this,2);doCalPrice(this,'${pricedetail.detail_index}',1);" onKeyPress="javascript:keyPress(this);">
									
									<br/>
									税率：<input name="tax_rate" type="text" class="input-edit" value="${pricedetail.tax_rate}" onChange="subReduNum(this,2);doCalPrice(this,'${pricedetail.detail_index}',1);" onKeyPress="javascript:keyPress(this);" /><br/>
									折后价：<input name="discount_net_price" class="input-unEdit words-blue" readonly type="text" value="${pricedetail.priceAfterDiscount}" /><br/>
									折后金额：<input name="discount_net_sum" class="input-edit" type="text" value="${pricedetail.amountAfterDiscount}" onChange="subReduNum(this,'${PRICE_PRECISION}');doCalPrice(this,'${pricedetail.detail_index}',2);" onKeyPress="javascript:keyPress(this);" /><br/>
									</td>
									<td class="td3">${pricedetail.memo}</td>
								</tr>
							</c:forEach>
						</c:if>
					</table>
				</div>
			</c:if>
			
			<div class="bidroom">
				<div class="margin20">
				</div>
				<div class="conner1">
					<div class="message">
						<div class="textrow">
						</div>
						<div class="buttonrow">
							<input type="submit" class="buttonok" value="提交" onClick="doQuote(true)" />
							&nbsp;&nbsp;
							<input type="submit" class="buttonok" value="保存" onClick="doQuote(false)" />
						</div>
					</div>
				</div>
			</div>
			
			<div class="margin10">
			</div>
		</div>
		</form>
		<form id="calpriceform" name="calpriceform" method="post" action="<%=basePath%>/sourcing/biddingprojlist/calprice">
			<!-- 集团 -->
			<input type="hidden" id="pk_group_cal" name="pk_group_cal" value="${PURPROJECT_FORM.pk_group}"/>
			<input type="hidden" id="pk_org_cal" name="pk_org_cal" value="${PURPROJECT_FORM.pk_org}"/>
			<!-- 产品 -->
			<input type="hidden" id="pk_prod_cal" name="pk_prod_cal" value=""/>
			<!-- 报价币种 -->
			<input type="hidden" id="pk_currency_cal" name="pk_currency_cal" value="${PURPROJECT_FORM.pk_currency}"/>
			<!-- 报价单位 -->
			<input type="hidden" id="pk_unit_cal" name="pk_unit_cal" value=""/>
			<!-- 主单位 -->
			<input type="hidden" id="pk_primary_unit_cal" name="pk_primary_unit_cal" value=""/>
			<!-- 报价数量 -->
			<input type="hidden" id="amount_cal" name="amount_cal" value=""/>
			<!-- 主数量 -->
			<input type="hidden" id="primary_amount_cal" name="primary_amount_cal" value=""/>
			<!-- 换算率 -->
			<input type="hidden" id="conversion_rate_cal" name="conversion_rate_cal" value=""/>
			<!-- 扣税类别 -->
			<input type="hidden" id="tax_type_cal" name="tax_type_cal" value=""/>
			<!-- 税率 -->
			<input type="hidden" id="tax_rate_cal" name="tax_rate_cal" value=""/>
			<!-- 折扣率 -->
			<input type="hidden" id="discount_rate_cal" name="discount_rate_cal" value=""/>
			<!-- 含税单价 -->
			<input type="hidden" id="has_tax_price_cal" name="has_tax_price_cal" value=""/>
			<!-- 含税金额 -->
			<input type="hidden" id="has_tax_sum_cal" name="has_tax_sum_cal" value=""/>
			<!-- 含税净价 -->
			<input type="hidden" id="has_tax_net_price_cal" name="has_tax_net_price_cal" value=""/>
			<!-- 主含税净价 -->
			<input type="hidden" id="primary_hastax_net_price_cal" name="primary_hastax_net_price_cal" value=""/>
			<!-- 无税单价 -->
			<input type="hidden" id="no_tax_price_cal" name="no_tax_price_cal" value=""/>
			<!-- 无税金额 -->
			<input type="hidden" id="no_tax_sum_cal" name="no_tax_sum_cal" value=""/>
			<!-- 无税净价 -->
			<input type="hidden" id="no_tax_net_price_cal" name="no_tax_net_price_cal" value=""/>
			<!-- 主无税净价 -->
			<input type="hidden" id="primary_notax_net_price_cal" name="primary_notax_net_price_cal" value=""/>
			<!-- 价税合计 -->
			<input type="hidden" id="price_tax_sum_cal" name="price_tax_sum_cal" value=""/>
			<input type="hidden" id="tax_sum_cal" name="tax_sum_cal" value=""/>
			<!-- 是否影响单价 -->
			<input type="hidden" id="changUnitPrice" name="changUnitPrice" value=""/>
			<!-- 计算字段顺序 -->
			<input type="hidden" id="property_cal" name="property_cal" value="has_tax_price"/>
			<!-- 计算行 -->
			<input type="hidden" id="row_no" name="row_no" value=""/>
		</form>
		<script language="javascript">
			//合计金额
			var totalAmount = document.getElementsByName("total_amount");
			//数量
			var amountDisplay = document.getElementsByName("amount_display");
			var amountPrecision = document.getElementsByName("amount_precision");
			//含税单价
			var hasTaxPrice = document.getElementsByName("has_tax_price");
			//税率
			var taxRate = document.getElementsByName("tax_rate");
			//折扣率
			var detailDiscount = document.getElementsByName("detail_discount");
			//折后价（含税净价或者无税竞价，统一取含税净价）
			var hasTaxNetPrices = document.getElementsByName("discount_net_price");
			//折后金额（价税合计）
			var priceTaxSums = document.getElementsByName("discount_net_sum");
			function doCalPrice(obj,index,calType){
				if(obj.value == "" || obj.value == null){
					return;
				}
				var editRow = 0;
				editRow = index - 1;
				//物料主健
				var prodPks = document.getElementsByName("pk_prod_v");
				document.calpriceform.pk_prod_cal.value = prodPks[editRow].value;
				//报价单位
				var prodUnitPks = document.getElementsByName("pk_prod_unit");
				document.calpriceform.pk_unit_cal.value = prodUnitPks[editRow].value;
				//数量
				var amounts = document.getElementsByName("amount");  
				document.calpriceform.amount_cal.value = amounts[editRow].value;
				//含税单价
				var hasTaxPrices = document.getElementsByName("has_tax_price");
				//折后金额（价税合计）
				var discountNetSum = document.getElementsByName("discount_net_sum");
				if((hasTaxPrices[editRow].value == "" || hasTaxPrices[editRow].value == null)
					&& (discountNetSum[editRow].value == "" || discountNetSum[editRow].value == null)){
					return;
				}
				document.calpriceform.has_tax_price_cal.value = hasTaxPrices[editRow].value;
				document.calpriceform.price_tax_sum_cal.value = discountNetSum[editRow].value;
				//税率
				var taxRates = document.getElementsByName("tax_rate");
				if(taxRates[editRow].value == "" || taxRates[editRow].value == null){
					taxRates[editRow].value = "0.00";
				}
				document.calpriceform.tax_rate_cal.value = taxRates[editRow].value;
				//折扣率
				var discountRates = document.getElementsByName("detail_discount");
				if(discountRates[editRow].value == "" || discountRates[editRow].value == null){
					return;
				}
				document.calpriceform.discount_rate_cal.value = discountRates[editRow].value;
				//行号
				document.calpriceform.row_no.value = index - 1;
				//计算字段
				if(hasTaxPrices[editRow].value != "" && hasTaxPrices[editRow].value != null && calType == 1){
					document.calpriceform.property_cal.value = "has_tax_price";
					document.calpriceform.changUnitPrice.value = "false";
				}else{
					document.calpriceform.property_cal.value = "price_tax_sum";
					document.calpriceform.changUnitPrice.value = "true";
				}
				//提交表单
				var options2 = {
					beforeSubmit : showRequest2, 
					success : showResponse2
				};
				$('#calpriceform').ajaxSubmit(options2);
			}
		
			function showRequest2(formData, jqForm, options) {
				//alert("formData:="+formData);
			}
			
			function showResponse2(responseText, statusText, xhr, $form) {
				//alert(responseText);
				// 0:报价数量|1:税率|2:折扣率|3:含税单价|4:价税合计（含税金额）|5:含税净价|6:主含税净价|7:无税单价|8:无税金额|9:无税净价|10:主无税净价|11:税e|12:行号
				var responseArr = responseText.split("|");
				//含税单价
				var hasTaxPrices = document.getElementsByName("has_tax_price");
				hasTaxPrices[responseArr[12]].value = responseArr[3];
				//税率
				var taxRates = document.getElementsByName("tax_rate");
				taxRates[responseArr[12]].value = responseArr[1];
				//折扣率
				var discountRates = document.getElementsByName("detail_discount");
				discountRates[responseArr[12]].value = responseArr[2];
				//折后价（含税净价或者无税竞价，统一取含税净价）
				var hasTaxNetPrices = document.getElementsByName("discount_net_price");
				hasTaxNetPrices[responseArr[12]].value = responseArr[5];
				//折后金额（价税合计）
				var priceTaxSums = document.getElementsByName("discount_net_sum");
				priceTaxSums[responseArr[12]].value = responseArr[4];
				//更新报价单元合计数据
				var isProdItem = document.getElementsByName("is_prod_item_cal");
				var totalAmount = document.getElementsByName("total_amount");
				for(var i=0;i<isProdItem.length;i++){
					if(isProdItem[i].value == "Y"){
						totalAmount[i].value = "";
						for(var j=0;j<priceTaxSums.length;j++){
							if(priceTaxSums[j].value != "" && priceTaxSums[j].value != null){
								if(totalAmount[i].value != "" && priceTaxSums[i].value != null){
									totalAmount[i].value = parseFloat(totalAmount[i].value) + parseFloat(priceTaxSums[j].value);
								}else{
									totalAmount[i].value = parseFloat(priceTaxSums[j].value);
								} 
							}
						}
						subReduNum(totalAmount[i],'${MONEY_PRECISION}');
						break;
					}
				}
			}
			
			function doQuote(bsubmit){
				$("#data_submit").val(bsubmit);
				document.quoteform.action = "<%=basePath%>/sourcing/biddingprojlist/doquote";
			}
			
			// pre-submit callback 
			function showRequest(formData, jqForm, options) {
				var status = "<%=strStepExeStatus%>";
				var bResult = true;
				//if(status != "2"){
					//alert("环节已完成或已终止，无法提交报价数据！");
					//bResult = false;
				//}
				if(bResult){
					bResult = checkInput();
					//签名
					<%if (isClientCa) {%>
						bResult = doVerifyPriceData();
					<%}%>
				}
				if(bResult){
					//校验供应商设置的最低总价
					bResult = checkLowPrice();
				}
				return bResult;
			}
		
			// post-submit callback 
			function showResponse(responseText, statusText, xhr, $form) {
				if(responseText.indexOf("error:") > -1){
					responseText = responseText.substring(6);
					alert(responseText);
					return;
				}
				var responseArr = responseText.split("|");
				var headPks = document.getElementsByName("pk_pricedata_h");
				var bodyPks = document.getElementsByName("pk_pricedata_b");
				var i = 0;
				for(i=0;i<headPks.length;i++){
					headPks[i].value = responseArr[i];
				}
				if(responseArr.length > i){
					for(j=0;j<bodyPks.length;j++){
						bodyPks[j].value = responseArr[i+j];
					}
				}
				//根据竞价策略设置报价默认值
				if(document.quoteform.data_submit.value == "true"){
					resetPrice();
				}
				alert("操作成功！");
			}
	
			//校验必输项
			function checkInput(){
				var bResult = true;
				var nullMsg = "";
				var digitMsg = "";
				var cellItems = new Array();
				cellItems[0] = hasTaxPrice;
				cellItems[1] = taxRate;
				cellItems[2] = detailDiscount;
				var cellNames = new Array();
				cellNames[0] = "含税单价";
				cellNames[1] = "税率";
				cellNames[2] = "折扣率";
				//数量
				var fieldValue;
				//是否有产品明细行已报价
				var bIsQuoted = false;
				var bIsPartPrice = "<%=strIsPartPrice%>";
				//检查报价明细的含税单价、税率、折扣率
				for(var i=0;i<hasTaxPrice.length;i++){
					for(var j=0;j<cellItems.length;j++){
						cellItems[j][i].value = trim(cellItems[j][i].value);
						fieldValue = cellItems[j][i].value;
						if(fieldValue == ""){
							if(null != nullMsg){
								nullMsg = nullMsg + "\r\n";
							}
							nullMsg = nullMsg + "报价明细第" + (i+1) + "行" + cellNames[j] + "不能为空！";
						}else {
							bIsQuoted = true;
							if(isNaN(fieldValue)){
								if(null != digitMsg){
									digitMsg = digitMsg + "\r\n";
								}
								digitMsg = digitMsg + "报价明细第" + (i+1) + "行" + cellNames[j] + "必须为数字！";
							}
						}
					}
				}
				//如果允许部分报价，且有部分产品报价，则不提示未输入报错信息
				if(bIsPartPrice == "Y" && bIsQuoted){
					nullMsg = "";
				}
				//检查报价单元的合计金额
				for(var i=0;i<totalAmount.length;i++){
					totalAmount[i].value = trim(totalAmount[i].value);
					fieldValue = totalAmount[i].value;
					if(fieldValue == ""){
						if(null != nullMsg){
							nullMsg = nullMsg + "\r\n";
						}
						nullMsg = nullMsg + "报价单元第" + (i+1) + "行合计金额不能为空！";
					}else if(isNaN(fieldValue)){
						if(null != digitMsg){
							digitMsg = digitMsg + "\r\n";
						}
						digitMsg = digitMsg + "报价单元第" + (i+1) + "行合计金额必须为数字！";
					}
				}
				if(nullMsg != ""){
					alert(nullMsg);
					bResult = false;
				}
				if(digitMsg != ""){
					alert(digitMsg);
					bResult = false;
				}
				return bResult;
			}
			
			//根据竞价策略设置报价默认值
			function resetPrice(){
				var isMnyDown = document.quoteform.is_mny_down.value;
				var downPercent = document.quoteform.down_percent.value;
				var downPrice = document.quoteform.down_price.value;
				var downPercentMny = document.quoteform.down_percent_mny.value;
				var downPriceMny = document.quoteform.down_price_mny.value;
				var hasTaxPrice = document.getElementsByName("has_tax_price");
				var hasTaxMny = document.getElementsByName("discount_net_sum");
				if(isMnyDown == "N"){
					if(null != downPercent && "" != downPercent){
						for(i=0;i<hasTaxPrice.length;i++){
							hasTaxPrice[i].value = hasTaxPrice[i].value - parseInt(hasTaxPrice[i].value)/100*parseInt(downPercent);
							hasTaxPrice[i].onchange();
						}
					}else if(null != downPrice && "" != downPrice){
						for(i=0;i<hasTaxPrice.length;i++){
							hasTaxPrice[i].value = parseInt(hasTaxPrice[i].value)-parseInt(downPrice);
							hasTaxPrice[i].onchange();
						}
					}
				}else{
					if(null != downPercentMny && "" != downPercentMny){
						for(i=0;i<hasTaxMny.length;i++){
							hasTaxMny[i].value = hasTaxMny[i].value - parseInt(hasTaxMny[i].value)/100*parseInt(downPercentMny);
							hasTaxMny[i].onchange();
						}
					}else if(null != downPriceMny && "" != downPriceMny){
						for(i=0;i<hasTaxMny.length;i++){
							hasTaxMny[i].value = parseInt(hasTaxMny[i].value)-parseInt(downPriceMny);
							hasTaxMny[i].onchange();
						}
					}
				}
			}
			
			//校验供应商设置的最低总价
			function checkLowPrice(){
				var bResult = true;
				var lowPrice = document.quoteform.low_price.value;
				if(null != lowPrice && "" != lowPrice){
					var dLowPrice = parseInt(lowPrice);
					var dTotalPrice = 0;
					var totalPrice = document.getElementsByName("total_amount");
					for(var i=0;i<totalPrice.length;i++){
						dTotalPrice = dTotalPrice + parseInt(totalPrice[i].value);
					}
					if(dLowPrice > dTotalPrice){
						bResult = confirm("总价低于最低价，是否继续操作？");
					}
				}
				return bResult;
			}
			//报价数据签名
			function doVerifyPriceData(){
				//报价单元合计金额
				var totalPrice = document.getElementsByName("total_amount");
				//是否产品项
				var isProdItem = document.getElementsByName("is_prod_item");
				//产品明细报价
				//数量
				var amount = document.getElementsByName("amount");
				//含税单价
				var hasTaxPrice = document.getElementsByName("has_tax_price");
				//税率
				var taxRate = document.getElementsByName("tax_rate");
				//折扣率
				var detailDiscount = document.getElementsByName("detail_discount");
				//待签名消息串
				var strVerifyPriceData = "";
				//证书SN
				var strSn = getSN("${USER_CODE}");
				if(strSn == null || strSn == ""){
					alert("请插入Key后再进行操作！");
					return false;
				}
				document.quoteform.casn.value = strSn;
				for(var i=0;i<totalPrice.length;i++){
					strVerifyPriceData = totalPrice[i].value + "|";
					if(isProdItem[i].value == "Y" && amount != null){
						for(var j=0;j<amount.length;j++){
							strVerifyPriceData = strVerifyPriceData + amount[j].value + "|";
							strVerifyPriceData = strVerifyPriceData + hasTaxPrice[j].value + "|";
							strVerifyPriceData = strVerifyPriceData + taxRate[j].value + "|";
							strVerifyPriceData = strVerifyPriceData + detailDiscount[j].value + "|";
						}
					}
					//签名
					document.getElementsByName("signature")[i].value = signmessage(strVerifyPriceData,"${USER_CODE}");
				}
				return true;
			}
			
			//供应商被踢出
			function kickLogout(reason){
				//var url = "<%=basePath%>/sourcingcoll/quotelogin.jsp?pkProj=${ONLINEQUOTE_FORM.pk_pur_project}"+"&pkProjStep=${ONLINEQUOTE_FORM.pk_purproj_step}";
				var url = "<%=basePath%>/";
				alert("你被后台管理员踢出竞价室！");
				document.location.href = url;
			}
			
			//竞价须知
			function getQuoteInform(){
				var title = "竞价须知";
				var url = "<%=basePath%>/sourcingcoll/quoteinform.jsp";
				var vTop = (window.screen.availHeight-30-500)/2;
				var vLeft = (window.screen.availWidth-10-420)/2;
				window.open(url,'' ,'width=500,height=420,location=no,top='+vTop+',left='+vLeft);
				//var url = "url:post?<%=basePath%>/sourcingcoll/quoteinform.jsp";
				//dialog(title, url,"500", "auto", "", "");
			}
			//查看报价历史
			function getOldPrice(){
				var title = "查看报价历史";
				var url = "<%=basePath%>/sourcing/biddingprojlist/getoldquote?projPk=${PURPROJECT_FORM.pk_pur_project}&onlineQuotePk=${ONLINEQUOTE_FORM.pk_onlinequote_h}&quoteType=${ONLINEQUOTE_FORM.quote_type}&quote_index=0";
				window.open(url,'' ,'width=1024,height=768,location=yes');
			}
			//导出报价
			function exportPrice(){
				document.quoteform.action = "<%=basePath%>/sourcing/biddingprojlist/haspricedata";
				//检查是否有报价
				var options3 = {
					beforeSubmit : showRequest3, 
					success : showResponse3
				};
				$('#quoteform').ajaxSubmit(options3);
			}
			function showRequest3(formData, jqForm, options) {
				//alert("formData:="+formData);
			}
			function showResponse3(responseText, statusText, xhr, $form) {
				if(responseText == "Y"){
					document.quoteform.action = "<%=basePath%>/sourcing/biddingprojlist/doexport";
					document.quoteform.submit();
				}else{
					alert("无报价数据！");
				}
			}
			//设置降价策略
			function setQuoteRule(){
				var downPercent = document.quoteform.down_percent.value;
				var downPrice = document.quoteform.down_price.value;
				var downPercentMny = document.quoteform.down_percent_mny.value;
				var downPriceMny = document.quoteform.down_price_mny.value;
				var lowPrice = document.quoteform.low_price.value;
				var title = "设置降价策略";
				var url = "<%=basePath%>/sourcingcoll/quotepolicy.jsp?onlineQuotePk=${ONLINEQUOTE_FORM.pk_onlinequote_h}&downPercent="+downPercent+"&downPrice="+downPrice+"&downPercentMny="+downPercentMny+"&downPriceMny="+downPriceMny+"&lowPrice="+lowPrice+"&mnyPrecision=${MONEY_PRECISION}&pricePrecision=${PRICE_PRECISION}";
				window.open(url,'' ,'width=1024,height=768,location=no');
			}
			
			//批量修改价格、折扣率、税率
			function doUptValue(flag){
				var url,title;
				if("1" == flag){
					//折扣率
					url = "iframe:<%=basePath%>/sourcingcoll/batcheditdiscount.jsp";
					title = "批量修改折扣率";
				}else if("2" == flag){
					//税率
					url = "iframe:<%=basePath%>/sourcingcoll/batchedittaxrate.jsp?price_precision=${PRICE_PRECISION}";
					title = "批量修改税率";
				}
				dialog(title, url,"300", "100", "", "",320);
			}
			//设置显示值
			//合计金额
			if(null != totalAmount){
				for(var i=0;i<totalAmount.length;i++){
					subReduNum(totalAmount[i],'${MONEY_PRECISION}');
				}
			}
			//数量
			if(null != amountDisplay){
				for(var i=0;i<amountDisplay.length;i++){
					subReduNum(amountDisplay[i],amountPrecision[i].value);
				}
			}
			//含税单价
			if(null != hasTaxPrice){
				for(var i=0;i<hasTaxPrice.length;i++){
					subReduNum(hasTaxPrice[i],'${PRICE_PRECISION}');
				}
			}
			//税率
			if(null != taxRate){
				for(var i=0;i<taxRate.length;i++){
					subReduNum(taxRate[i],2);
				}
			}
			//折扣率
			if(null != detailDiscount){
				for(var i=0;i<detailDiscount.length;i++){
					subReduNum(detailDiscount[i],2);
				}
			}
			//折后价（含税净价或者无税竞价，统一取含税净价）
			if(null != hasTaxNetPrices){
				for(var i=0;i<hasTaxNetPrices.length;i++){
					subReduNum(hasTaxNetPrices[i],'${PRICE_PRECISION}');
				}
			}
			//折后金额（价税合计）
			if(null != priceTaxSums){
				for(var i=0;i<priceTaxSums.length;i++){
					subReduNum(priceTaxSums[i],'${MONEY_PRECISION}');
				}
			}
		</script>
	</body>
</html>
